import { ApiPropertyOptional } from '@nestjs/swagger';
import { BasePaginationDto } from '@nbase/nest-mods';
import { IsIn, IsInt, IsOptional, IsString } from 'class-validator';
import { Type } from 'class-transformer';
import { IQueryUser, USER_STATUS_VALUES } from '@nbase/shared';

/**
 * 查询用户 DTO
 */
export class QueryUserDto extends BasePaginationDto implements IQueryUser {
  // sortBy 字段继承自基类，不限制具体字段
  @ApiPropertyOptional({
    description: '用户名关键词',
    example: 'zhang',
  })
  @IsOptional()
  @IsString()
  username?: string;

  @ApiPropertyOptional({
    description: '昵称关键词',
    example: '张',
  })
  @IsOptional()
  @IsString()
  nickname?: string;

  @ApiPropertyOptional({
    description: '状态（1.启用 2.禁用）',
    example: 1,
    enum: USER_STATUS_VALUES,
  })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @IsIn(USER_STATUS_VALUES)
  status?: number;
}

